import Vue from 'vue'
import Vuex from 'vuex'

import http from './common/http'
import util from './common/util'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
  	menuList : [],
  },
  getters : {
  	menuList : state => state.menuList,
  },
  mutations: {
  	setMenuList (state, obj) {
        state.menuList = obj;
    },
  },
  actions: {
  	async getMenuList ({ commit, dispatch}, para) {

			const res = await http('menuList');

			//console.log(res);

			//const result = util.transData(res, 'id', 'pid', 'children');



			// let systemList = [];
			// result[0].children.forEach((item, index) => {
			// 	systemList.push({
			// 		name : item.name,
			// 		index,
			// 	});
			// });

			commit('setMenuList', res);
			// commit('setSystemList', systemList);
			// commit('setDefaultMenu');
	},
  }
})
